//
//  ASectionController.m
//  BaseProject
//
//  Created by itzhaolei on 2024/5/13.
//

#import "ASectionController.h"
#import "CommonCollectionViewCell.h"

@interface ASectionController()

/// 演示数据变化
@property (nonatomic, unsafe_unretained) NSInteger num;

@end

@implementation ASectionController

- (instancetype)initWithCoordinator:(CommonListCoordinator<ListCoordinatorDelegate> *)coordinator {
    if (self = [super initWithCoordinator:coordinator]) {
        NSLog(@"A区行为被初始化");
    }
    return self;
}

#pragma mark - Overwrite

// 当前区域内的单元格所占大小
- (CGSize)sizeForItemAtIndex:(NSInteger)index {
    return CGSizeMake(UIScreen.mainScreen.bounds.size.width / 2, 200);
}

// 当前区域内的单元格构建与复用
- (__kindof UICollectionViewCell *)cellForItemAtIndex:(NSInteger)index {
    CommonCollectionViewCell *cell = [self.collectionContext dequeueReusableCellOfClass:[CommonCollectionViewCell class] forSectionController:self atIndex:index];
    cell.contentLabel.text = [NSString stringWithFormat:@"点击数据发生变化:\n%ld", self.num];
    return cell;
}

// 当前区域内的点击事件
- (void)didSelectItemAtIndex:(NSInteger)index {
    self.num += 1;
    [self.delegate reloadSectionController:self];
}

@end
